package com.umfb.mongodb;

import com.alibaba.dubbo.config.annotation.Service;
import com.umfb.demo.entity.Player;
import com.umfb.demo.service.IMongoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;

/**
 * Created by zcah on 18-5-28.
 */
@Service
public class MongoServiceImpl implements IMongoService {
    public static  final Logger logger = LoggerFactory.getLogger(MongoServiceImpl.class);

    @Autowired
    private MongoTemplate mongoTemplate;
    @Override
    public String addDemoPlayer(Player player) {

        if(player!=null){
            mongoTemplate.save(player);

            return player.getUserId();
        }else{
            logger.info("Mongodb Service {player.getUserId}"+player.getUserId());
            return null;
        }

    }
}
